08_analysis_mod_param

Author

Angelique Porciani

Published

Last Updated on 16 October, 2025

Import data

Code
library(glmmTMB)
library(emmeans)
library(DHARMa)
library(car)
library(lme4)
library(performance)
library(dplyr)
library(coxme)
library(ggplot2)
## Analysis split for red and orange 

data_complete <- readRDS("../output/data_complete.rds")
data_complete_SP <- readRDS("../output/data_complete_SP.rds")

Orange

Code
# Modèle Orange concentration and inf 20 time lost
data_orange_inf20 <- data_complete %>% dplyr::filter(Experiment=="Orange"&Prop_time_lost<0.2)
data_orange_SP <- data_complete_SP %>% dplyr::filter(Experiment=="Orange" & Prop_time_lost<0.2)

Prop time moving

Code
### Prop time moving 
ggplot(data_orange_inf20)+
  geom_boxplot(aes(x=Traitement, y=Prop_time_moving, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Prop_time_moving, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
modPTM <- glmmTMB(sqrt(Prop_time_moving)~Traitement+sexe+(1|Replicat), 
                             data=data_orange_inf20)
res <- simulateResiduals(modPTM)
plot(res)

Code
summary(modPTM)
 Family: gaussian  ( identity )
Formula:          sqrt(Prop_time_moving) ~ Traitement + sexe + (1 | Replicat)
Data: data_orange_inf20

     AIC      BIC   logLik deviance df.resid 
  -400.4   -384.0    205.2   -410.4      190 

Random effects:

Conditional model:
 Groups   Name        Variance  Std.Dev.
 Replicat (Intercept) 0.0005099 0.02258 
 Residual             0.0068948 0.08304 
Number of obs: 195, groups:  Replicat, 5

Dispersion estimate for gaussian family (sigma^2): 0.00689 

Conditional model:
                              Estimate Std. Error z value Pr(>|z|)    
(Intercept)                  0.5210535  0.0141468   36.83   <2e-16 ***
TraitementPermethrin_orange -0.0009606  0.0119528   -0.08    0.936    
sexeM                        0.0180279  0.0120840    1.49    0.136    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
emmeans(modPTM, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement        sexe response     SE  df lower.CL upper.CL t.ratio p.value
 Control           F       0.271 0.0147 190    0.243    0.301  36.832  <.0001
 Permethrin_orange F       0.270 0.0152 190    0.241    0.301  35.624  <.0001
 Control           M       0.291 0.0157 190    0.260    0.322  36.913  <.0001
 Permethrin_orange M       0.290 0.0157 190    0.259    0.321  36.819  <.0001

Confidence level used: 0.95 
Intervals are back-transformed from the sqrt scale 
Tests are performed on the sqrt scale 

$contrasts
 contrast                                   estimate     SE  df lower.CL
 Control F - Permethrin_orange F            0.000961 0.0120 190  -0.0300
 Control F - Control M                     -0.018028 0.0121 190  -0.0493
 Control F - Permethrin_orange M           -0.017067 0.0166 190  -0.0601
 Permethrin_orange F - Control M           -0.018989 0.0174 190  -0.0640
 Permethrin_orange F - Permethrin_orange M -0.018028 0.0121 190  -0.0493
 Control M - Permethrin_orange M            0.000961 0.0120 190  -0.0300
 upper.CL t.ratio p.value
   0.0319   0.080  0.9998
   0.0133  -1.492  0.4444
   0.0260  -1.027  0.7339
   0.0260  -1.093  0.6940
   0.0133  -1.492  0.4444
   0.0319   0.080  0.9998

Note: contrasts are still on the sqrt scale 
Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
P value adjustment: tukey method for comparing a family of 4 estimates 

Traveled distance

Code
### Traveled distance Moving

ggplot(data_orange_inf20)+
  geom_boxplot(aes(x=Traitement, y=Traveled_Dist_Moving, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Traveled_Dist_Moving, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
modTVM <- glmmTMB(Traveled_Dist_Moving~Traitement*sexe+(1|Replicat), 
                  data=data_orange_inf20)

Anova(modTVM)
Analysis of Deviance Table (Type II Wald chisquare tests)

Response: Traveled_Dist_Moving
                 Chisq Df Pr(>Chisq)
Traitement      0.7800  1     0.3771
sexe            1.1144  1     0.2911
Traitement:sexe 0.9158  1     0.3386
Code
modTVM <- glmmTMB(Traveled_Dist_Moving~Traitement+sexe+(1|Replicat), 
                  data=data_orange_inf20)

res <- simulateResiduals(modTVM)
plot(res)

Code
summary(modTVM)
 Family: gaussian  ( identity )
Formula:          Traveled_Dist_Moving ~ Traitement + sexe + (1 | Replicat)
Data: data_orange_inf20

     AIC      BIC   logLik deviance df.resid 
  2817.6   2833.9  -1403.8   2807.6      190 

Random effects:

Conditional model:
 Groups   Name        Variance Std.Dev.
 Replicat (Intercept)  13379   115.7   
 Residual             100028   316.3   
Number of obs: 195, groups:  Replicat, 5

Dispersion estimate for gaussian family (sigma^2): 1e+05 

Conditional model:
                            Estimate Std. Error z value Pr(>|z|)    
(Intercept)                   857.65      64.03  13.395   <2e-16 ***
TraitementPermethrin_orange   -40.11      45.53  -0.881    0.378    
sexeM                          48.49      46.03   1.054    0.292    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
emmeans(modTVM, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement        sexe emmean   SE  df lower.CL upper.CL t.ratio p.value
 Control           F       858 64.0 190      731      984  13.395  <.0001
 Permethrin_orange F       818 65.5 190      688      947  12.482  <.0001
 Control           M       906 65.5 190      777     1035  13.832  <.0001
 Permethrin_orange M       866 65.5 190      737      995  13.221  <.0001

Confidence level used: 0.95 

$contrasts
 contrast                                  estimate   SE  df lower.CL upper.CL
 Control F - Permethrin_orange F              40.11 45.5 190    -77.9    158.1
 Control F - Control M                       -48.49 46.0 190   -167.8     70.8
 Control F - Permethrin_orange M              -8.38 63.2 190   -172.3    155.5
 Permethrin_orange F - Control M             -88.60 66.2 190   -260.2     83.0
 Permethrin_orange F - Permethrin_orange M   -48.49 46.0 190   -167.8     70.8
 Control M - Permethrin_orange M              40.11 45.5 190    -77.9    158.1
 t.ratio p.value
   0.881  0.8147
  -1.054  0.7181
  -0.132  0.9992
  -1.338  0.5397
  -1.054  0.7181
   0.881  0.8147

Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
P value adjustment: tukey method for comparing a family of 4 estimates 

avg speed moving

Code
### Average speed moving 

ggplot(data_orange_inf20)+
  geom_boxplot(aes(x=Traitement, y=Average_Speed_Moving, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Average_Speed_Moving, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
modAVM <- glmmTMB(Average_Speed_Moving~Traitement*sexe+(1|Replicat), 
                  data=data_orange_inf20)

Anova(modAVM)
Analysis of Deviance Table (Type II Wald chisquare tests)

Response: Average_Speed_Moving
                 Chisq Df Pr(>Chisq)
Traitement      2.5755  1     0.1085
sexe            0.5816  1     0.4457
Traitement:sexe 0.3221  1     0.5704
Code
modAVM <- glmmTMB(Average_Speed_Moving~Traitement+sexe+(1|Replicat), 
                  data=data_orange_inf20)

res <- simulateResiduals(modAVM)
plot(res)

Code
summary(modAVM)
 Family: gaussian  ( identity )
Formula:          Average_Speed_Moving ~ Traitement + sexe + (1 | Replicat)
Data: data_orange_inf20

     AIC      BIC   logLik deviance df.resid 
  -290.3   -273.9    150.1   -300.3      190 

Random effects:

Conditional model:
 Groups   Name        Variance Std.Dev.
 Replicat (Intercept) 0.001221 0.03494 
 Residual             0.012050 0.10977 
Number of obs: 195, groups:  Replicat, 5

Dispersion estimate for gaussian family (sigma^2): 0.0121 

Conditional model:
                            Estimate Std. Error z value Pr(>|z|)    
(Intercept)                  0.90172    0.02039   44.23   <2e-16 ***
TraitementPermethrin_orange -0.02534    0.01580   -1.60    0.109    
sexeM                       -0.01216    0.01595   -0.76    0.446    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
emmeans(modAVM, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement        sexe emmean     SE  df lower.CL upper.CL t.ratio p.value
 Control           F     0.902 0.0204 190    0.862    0.942  44.230  <.0001
 Permethrin_orange F     0.876 0.0209 190    0.835    0.918  41.848  <.0001
 Control           M     0.890 0.0209 190    0.848    0.931  42.481  <.0001
 Permethrin_orange M     0.864 0.0209 190    0.823    0.906  41.299  <.0001

Confidence level used: 0.95 

$contrasts
 contrast                                  estimate     SE  df lower.CL
 Control F - Permethrin_orange F             0.0253 0.0158 190  -0.0156
 Control F - Control M                       0.0122 0.0160 190  -0.0292
 Control F - Permethrin_orange M             0.0375 0.0219 190  -0.0193
 Permethrin_orange F - Control M            -0.0132 0.0230 190  -0.0727
 Permethrin_orange F - Permethrin_orange M   0.0122 0.0160 190  -0.0292
 Control M - Permethrin_orange M             0.0253 0.0158 190  -0.0156
 upper.CL t.ratio p.value
   0.0663   1.604  0.3790
   0.0535   0.762  0.8714
   0.0943   1.710  0.3212
   0.0464  -0.574  0.9398
   0.0535   0.762  0.8714
   0.0663   1.604  0.3790

Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
P value adjustment: tukey method for comparing a family of 4 estimates 

Max bout inactiv

Code
### Max bout inactiv 
data_orange_inf20_sub <- data_orange_inf20 %>% dplyr::filter(Max_bout_inactiv<1500)
ggplot(data_orange_inf20)+
  geom_boxplot(aes(x=Traitement, y=Max_bout_inactiv, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Max_bout_inactiv, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
ggplot(data_orange_inf20_sub)+
  geom_boxplot(aes(x=Traitement, y=Max_bout_inactiv, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Max_bout_inactiv, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
hist(data_orange_inf20_sub$Max_bout_inactiv)

Code
modMI <- glmmTMB(Max_bout_inactiv~Traitement*sexe+(1|Replicat), 
                 data=data_orange_inf20_sub, family=nbinom2())

Anova(modMI)
Analysis of Deviance Table (Type II Wald chisquare tests)

Response: Max_bout_inactiv
                 Chisq Df Pr(>Chisq)
Traitement      1.6419  1     0.2001
sexe            0.2349  1     0.6279
Traitement:sexe 0.7133  1     0.3984
Code
modMI <- glmmTMB(Max_bout_inactiv~Traitement+sexe+(1|Replicat), 
                 data=data_orange_inf20_sub, family=nbinom2(), zi=~1)

summary(modMI)
 Family: nbinom2  ( log )
Formula:          Max_bout_inactiv ~ Traitement + sexe + (1 | Replicat)
Zero inflation:                    ~1
Data: data_orange_inf20_sub

     AIC      BIC   logLik deviance df.resid 
  2173.0   2192.5  -1080.5   2161.0      186 

Random effects:

Conditional model:
 Groups   Name        Variance Std.Dev.
 Replicat (Intercept) 0.02673  0.1635  
Number of obs: 192, groups:  Replicat, 5

Dispersion parameter for nbinom2 family (): 2.19 

Conditional model:
                            Estimate Std. Error z value Pr(>|z|)    
(Intercept)                  4.77913    0.11128   42.95   <2e-16 ***
TraitementPermethrin_orange -0.12795    0.10006   -1.28    0.201    
sexeM                        0.04833    0.09950    0.49    0.627    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Zero-inflation model:
            Estimate Std. Error z value Pr(>|z|)
(Intercept)   -21.41    3214.48  -0.007    0.995
Code
res <- simulateResiduals(modMI)
plot(res)#  

Code
emmeans(modMI, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement        sexe response   SE  df asymp.LCL asymp.UCL null z.ratio
 Control           F         119 13.2 Inf      95.7       148    1  42.948
 Permethrin_orange F         105 11.8 Inf      84.0       131    1  41.263
 Control           M         125 14.1 Inf     100.1       156    1  42.711
 Permethrin_orange M         110 12.7 Inf      87.6       138    1  40.665
 p.value
  <.0001
  <.0001
  <.0001
  <.0001

Confidence level used: 0.95 
Intervals are back-transformed from the log scale 
Tests are performed on the log scale 

$contrasts
 contrast                                  ratio     SE  df asymp.LCL asymp.UCL
 Control F / Permethrin_orange F           1.137 0.1137 Inf     0.879      1.47
 Control F / Control M                     0.953 0.0948 Inf     0.738      1.23
 Control F / Permethrin_orange M           1.083 0.1538 Inf     0.752      1.56
 Permethrin_orange F / Control M           0.838 0.1175 Inf     0.585      1.20
 Permethrin_orange F / Permethrin_orange M 0.953 0.0948 Inf     0.738      1.23
 Control M / Permethrin_orange M           1.137 0.1137 Inf     0.879      1.47
 null z.ratio p.value
    1   1.279  0.5765
    1  -0.486  0.9623
    1   0.561  0.9437
    1  -1.257  0.5902
    1  -0.486  0.9623
    1   1.279  0.5765

Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
Intervals are back-transformed from the log scale 
P value adjustment: tukey method for comparing a family of 4 estimates 
Tests are performed on the log scale 

Max bout activ

Max speed

Code
### Max speed
ggplot(data_orange_inf20)+
  geom_boxplot(aes(x=Traitement, y=Max_speed, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Max_speed, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
modMS <- glmmTMB(Max_speed~Traitement*sexe+(1|Replicat), 
                  data=data_orange_inf20)
Anova(modMS)
Analysis of Deviance Table (Type II Wald chisquare tests)

Response: Max_speed
                 Chisq Df Pr(>Chisq)
Traitement      1.0983  1     0.2946
sexe            0.1671  1     0.6827
Traitement:sexe 0.1907  1     0.6624
Code
modMS <- glmmTMB(Max_speed~Traitement+sexe+(1|Replicat), 
                 data=data_orange_inf20)
summary(modMS)
 Family: gaussian  ( identity )
Formula:          Max_speed ~ Traitement + sexe + (1 | Replicat)
Data: data_orange_inf20

     AIC      BIC   logLik deviance df.resid 
    10.8     27.1     -0.4      0.8      188 

Random effects:

Conditional model:
 Groups   Name        Variance Std.Dev.
 Replicat (Intercept) 0.006635 0.08145 
 Residual             0.056243 0.23716 
Number of obs: 193, groups:  Replicat, 5

Dispersion estimate for gaussian family (sigma^2): 0.0562 

Conditional model:
                            Estimate Std. Error z value Pr(>|z|)    
(Intercept)                  3.01829    0.04626   65.25   <2e-16 ***
TraitementPermethrin_orange -0.03597    0.03434   -1.05    0.295    
sexeM                        0.01414    0.03461    0.41    0.683    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
res <- simulateResiduals(modMS)
plot(res)

Code
emmeans(modMS, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement        sexe emmean     SE  df lower.CL upper.CL t.ratio p.value
 Control           F      3.02 0.0463 188     2.93     3.11  65.246  <.0001
 Permethrin_orange F      2.98 0.0473 188     2.89     3.08  63.026  <.0001
 Control           M      3.03 0.0473 188     2.94     3.13  64.136  <.0001
 Permethrin_orange M      3.00 0.0474 188     2.90     3.09  63.185  <.0001

Confidence level used: 0.95 

$contrasts
 contrast                                  estimate     SE  df lower.CL
 Control F - Permethrin_orange F             0.0360 0.0343 188  -0.0531
 Control F - Control M                      -0.0141 0.0346 188  -0.1038
 Control F - Permethrin_orange M             0.0218 0.0479 188  -0.1023
 Permethrin_orange F - Control M            -0.0501 0.0496 188  -0.1787
 Permethrin_orange F - Permethrin_orange M  -0.0141 0.0346 188  -0.1038
 Control M - Permethrin_orange M             0.0360 0.0343 188  -0.0531
 upper.CL t.ratio p.value
   0.1250   1.047  0.7218
   0.0756  -0.409  0.9769
   0.1459   0.456  0.9684
   0.0785  -1.010  0.7439
   0.0756  -0.409  0.9769
   0.1250   1.047  0.7218

Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
P value adjustment: tukey method for comparing a family of 4 estimates 

Latency

Code
ggplot(data_orange_SP)+
  geom_boxplot(aes(x=Traitement, y=Latency, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Latency, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
hist(data_orange_SP$Latency)

Code
modLat <- glmmTMB(Latency~Traitement+sexe+(1|Replicat), 
                             data=data_orange_SP, family=nbinom1())
res <- simulateResiduals(modLat)
plot(res)

Code
summary(modLat)
 Family: nbinom1  ( log )
Formula:          Latency ~ Traitement + sexe + (1 | Replicat)
Data: data_orange_SP

     AIC      BIC   logLik deviance df.resid 
   835.8    852.2   -412.9    825.8      192 

Random effects:

Conditional model:
 Groups   Name        Variance Std.Dev. 
 Replicat (Intercept) 3.79e-09 6.157e-05
Number of obs: 197, groups:  Replicat, 5

Dispersion parameter for nbinom1 family (): 58.1 

Conditional model:
                     Estimate Std. Error z value Pr(>|z|)    
(Intercept)            1.6282     0.2647   6.152 7.64e-10 ***
TraitementPermethrin   0.4297     0.2200   1.953   0.0508 .  
sexeM                  0.3172     0.2185   1.452   0.1465    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
emmeans(modLat, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement sexe response   SE  df asymp.LCL asymp.UCL null z.ratio p.value
 Control    F        5.09 1.35 Inf      3.03      8.56    1   6.152  <.0001
 Permethrin F        7.83 1.99 Inf      4.76     12.89    1   8.096  <.0001
 Control    M        7.00 1.81 Inf      4.21     11.61    1   7.523  <.0001
 Permethrin M       10.75 2.53 Inf      6.78     17.04    1  10.109  <.0001

Confidence level used: 0.95 
Intervals are back-transformed from the log scale 
Tests are performed on the log scale 

$contrasts
 contrast                    ratio    SE  df asymp.LCL asymp.UCL null z.ratio
 Control F / Permethrin F    0.651 0.143 Inf     0.370      1.15    1  -1.953
 Control F / Control M       0.728 0.159 Inf     0.415      1.28    1  -1.452
 Control F / Permethrin M    0.474 0.142 Inf     0.219      1.02    1  -2.491
 Permethrin F / Control M    1.119 0.358 Inf     0.492      2.55    1   0.352
 Permethrin F / Permethrin M 0.728 0.159 Inf     0.415      1.28    1  -1.452
 Control M / Permethrin M    0.651 0.143 Inf     0.370      1.15    1  -1.953
 p.value
  0.2062
  0.4669
  0.0613
  0.9851
  0.4669
  0.2062

Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
Intervals are back-transformed from the log scale 
P value adjustment: tukey method for comparing a family of 4 estimates 
Tests are performed on the log scale 

Prop time alongside walls

Code
ggplot(data_orange_SP)+
  geom_boxplot(aes(x=Traitement, y=Prop_time_inside, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Prop_time_inside, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
modPTIW <- glmmTMB(sqrt(Prop_time_inside)~Traitement+sexe+(1|Replicat), 
                             data=data_orange_SP)
res <- simulateResiduals(modPTIW)
plot(res)

Code
summary(modPTIW)
 Family: gaussian  ( identity )
Formula:          sqrt(Prop_time_inside) ~ Traitement + sexe + (1 | Replicat)
Data: data_orange_SP

     AIC      BIC   logLik deviance df.resid 
  -392.9   -376.5    201.5   -402.9      192 

Random effects:

Conditional model:
 Groups   Name        Variance Std.Dev.
 Replicat (Intercept) 0.001720 0.04147 
 Residual             0.007135 0.08447 
Number of obs: 197, groups:  Replicat, 5

Dispersion estimate for gaussian family (sigma^2): 0.00713 

Conditional model:
                      Estimate Std. Error z value Pr(>|z|)    
(Intercept)           0.788644   0.021103   37.37   <2e-16 ***
TraitementPermethrin -0.007736   0.012114   -0.64    0.523    
sexeM                -0.007968   0.012228   -0.65    0.515    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
emmeans(modPTIW, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement sexe response     SE  df lower.CL upper.CL t.ratio p.value
 Control    F       0.622 0.0333 192    0.558    0.689  37.372  <.0001
 Permethrin F       0.610 0.0335 192    0.546    0.678  36.455  <.0001
 Control    M       0.609 0.0334 192    0.545    0.677  36.451  <.0001
 Permethrin M       0.597 0.0330 192    0.534    0.664  36.210  <.0001

Confidence level used: 0.95 
Intervals are back-transformed from the sqrt scale 
Tests are performed on the sqrt scale 

$contrasts
 contrast                    estimate     SE  df lower.CL upper.CL t.ratio
 Control F - Permethrin F    0.007736 0.0121 192  -0.0237   0.0391   0.639
 Control F - Control M       0.007968 0.0122 192  -0.0237   0.0397   0.652
 Control F - Permethrin M    0.015704 0.0167 192  -0.0276   0.0590   0.939
 Permethrin F - Control M    0.000232 0.0177 192  -0.0456   0.0461   0.013
 Permethrin F - Permethrin M 0.007968 0.0122 192  -0.0237   0.0397   0.652
 Control M - Permethrin M    0.007736 0.0121 192  -0.0237   0.0391   0.639
 p.value
  0.9194
  0.9149
  0.7839
  1.0000
  0.9149
  0.9194

Note: contrasts are still on the sqrt scale 
Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
P value adjustment: tukey method for comparing a family of 4 estimates 

Prop time moving alongside walls

Code
ggplot(data_orange_SP)+
  geom_boxplot(aes(x=Traitement, y=Prop_time_moving, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Prop_time_moving, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
modPTMs<- glmmTMB(sqrt(Prop_time_moving)~Traitement+sexe+(1|Replicat), 
                             data=data_orange_SP)
res <- simulateResiduals(modPTMs)
plot(res)

Code
summary(modPTMs)
 Family: gaussian  ( identity )
Formula:          sqrt(Prop_time_moving) ~ Traitement + sexe + (1 | Replicat)
Data: data_orange_SP

     AIC      BIC   logLik deviance df.resid 
  -359.2   -342.7    184.6   -369.2      192 

Random effects:

Conditional model:
 Groups   Name        Variance Std.Dev.
 Replicat (Intercept) 0.001648 0.04059 
 Residual             0.008511 0.09226 
Number of obs: 197, groups:  Replicat, 5

Dispersion estimate for gaussian family (sigma^2): 0.00851 

Conditional model:
                     Estimate Std. Error z value Pr(>|z|)    
(Intercept)           0.45702    0.02122  21.534   <2e-16 ***
TraitementPermethrin -0.01710    0.01323  -1.292    0.196    
sexeM                 0.01383    0.01337   1.034    0.301    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
emmeans(modPTMs, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement sexe response     SE  df lower.CL upper.CL t.ratio p.value
 Control    F       0.209 0.0194 192    0.172    0.249  21.534  <.0001
 Permethrin F       0.194 0.0190 192    0.158    0.233  20.367  <.0001
 Control    M       0.222 0.0203 192    0.183    0.264  21.795  <.0001
 Permethrin M       0.206 0.0195 192    0.169    0.246  21.089  <.0001

Confidence level used: 0.95 
Intervals are back-transformed from the sqrt scale 
Tests are performed on the sqrt scale 

$contrasts
 contrast                    estimate     SE  df lower.CL upper.CL t.ratio
 Control F - Permethrin F     0.01710 0.0132 192  -0.0172   0.0514   1.292
 Control F - Control M       -0.01383 0.0134 192  -0.0485   0.0208  -1.034
 Control F - Permethrin M     0.00327 0.0183 192  -0.0441   0.0506   0.179
 Permethrin F - Control M    -0.03093 0.0193 192  -0.0810   0.0192  -1.600
 Permethrin F - Permethrin M -0.01383 0.0134 192  -0.0485   0.0208  -1.034
 Control M - Permethrin M     0.01710 0.0132 192  -0.0172   0.0514   1.292
 p.value
  0.5689
  0.7298
  0.9980
  0.3813
  0.7298
  0.5689

Note: contrasts are still on the sqrt scale 
Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
P value adjustment: tukey method for comparing a family of 4 estimates 

Nb entries

Code
ggplot(data_orange_SP)+
  geom_boxplot(aes(x=Traitement, y=Nb_entries, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Nb_entries, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
modNbE<- glmmTMB(Nb_entries~Traitement+sexe+(1|Replicat), 
                             data=data_orange_SP, family=nbinom1())
res <- simulateResiduals(modNbE)
plot(res)

Code
summary(modNbE)
 Family: nbinom1  ( log )
Formula:          Nb_entries ~ Traitement + sexe + (1 | Replicat)
Data: data_orange_SP

     AIC      BIC   logLik deviance df.resid 
  2304.3   2320.8  -1147.2   2294.3      192 

Random effects:

Conditional model:
 Groups   Name        Variance Std.Dev.
 Replicat (Intercept) 0.04675  0.2162  
Number of obs: 197, groups:  Replicat, 5

Dispersion parameter for nbinom1 family (): 25.9 

Conditional model:
                     Estimate Std. Error z value Pr(>|z|)    
(Intercept)           5.44431    0.10448   52.11   <2e-16 ***
TraitementPermethrin  0.04563    0.04574    1.00    0.319    
sexeM                 0.06605    0.04564    1.45    0.148    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
emmeans(modNbE, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement sexe response   SE  df asymp.LCL asymp.UCL null z.ratio p.value
 Control    F         231 24.2 Inf       189       284    1  52.108  <.0001
 Permethrin F         242 25.5 Inf       197       298    1  52.239  <.0001
 Control    M         247 26.0 Inf       201       304    1  52.461  <.0001
 Permethrin M         259 27.0 Inf       211       318    1  53.183  <.0001

Confidence level used: 0.95 
Intervals are back-transformed from the log scale 
Tests are performed on the log scale 

$contrasts
 contrast                    ratio     SE  df asymp.LCL asymp.UCL null z.ratio
 Control F / Permethrin F    0.955 0.0437 Inf     0.849      1.07    1  -0.998
 Control F / Control M       0.936 0.0427 Inf     0.833      1.05    1  -1.447
 Control F / Permethrin M    0.894 0.0561 Inf     0.761      1.05    1  -1.782
 Permethrin F / Control M    0.980 0.0652 Inf     0.826      1.16    1  -0.307
 Permethrin F / Permethrin M 0.936 0.0427 Inf     0.833      1.05    1  -1.447
 Control M / Permethrin M    0.955 0.0437 Inf     0.849      1.07    1  -0.998
 p.value
  0.7508
  0.4698
  0.2820
  0.9900
  0.4698
  0.7508

Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
Intervals are back-transformed from the log scale 
P value adjustment: tukey method for comparing a family of 4 estimates 
Tests are performed on the log scale 

Rouge

Code
data_rouge_inf20 <- data_complete %>% dplyr::filter(Experiment=="Rouge"&Prop_time_lost<0.2)
data_rouge_SP <- data_complete_SP %>% dplyr::filter(Experiment=="Rouge"&Prop_time_lost<0.2)

Prop time moving

Code
ggplot(data_rouge_inf20)+
  geom_boxplot(aes(x=Traitement, y=Prop_time_moving, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Prop_time_moving, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
modPTM <- glmmTMB(sqrt(Prop_time_moving)~Traitement+sexe+(1|Replicat), 
                  data=data_rouge_inf20)

res <- simulateResiduals(modPTM)
plot(res)

Code
summary(modPTM)
 Family: gaussian  ( identity )
Formula:          sqrt(Prop_time_moving) ~ Traitement + sexe + (1 | Replicat)
Data: data_rouge_inf20

     AIC      BIC   logLik deviance df.resid 
  -260.6   -244.0    135.3   -270.6      200 

Random effects:

Conditional model:
 Groups   Name        Variance Std.Dev.
 Replicat (Intercept) 0.006165 0.07852 
 Residual             0.014773 0.12154 
Number of obs: 205, groups:  Replicat, 4

Dispersion estimate for gaussian family (sigma^2): 0.0148 

Conditional model:
                           Estimate Std. Error z value Pr(>|z|)    
(Intercept)                 0.29611    0.04189   7.069 1.56e-12 ***
TraitementPermethrin_rouge -0.06508    0.01760  -3.697 0.000218 ***
sexeM                       0.01060    0.01702   0.623 0.533268    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
emmeans(modPTM, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement       sexe response     SE  df lower.CL upper.CL t.ratio p.value
 Control          F      0.0877 0.0248 200   0.0456   0.1434   7.069  <.0001
 Permethrin_rouge F      0.0534 0.0199 200   0.0213   0.0999   5.358  <.0001
 Control          M      0.0941 0.0258 200   0.0501   0.1518   7.296  <.0001
 Permethrin_rouge M      0.0584 0.0208 200   0.0245   0.1067   5.604  <.0001

Confidence level used: 0.95 
Intervals are back-transformed from the sqrt scale 
Tests are performed on the sqrt scale 

$contrasts
 contrast                                estimate     SE  df lower.CL upper.CL
 Control F - Permethrin_rouge F            0.0651 0.0176 200  0.01947   0.1107
 Control F - Control M                    -0.0106 0.0170 200 -0.05469   0.0335
 Control F - Permethrin_rouge M            0.0545 0.0242 200 -0.00826   0.1172
 Permethrin_rouge F - Control M           -0.0757 0.0247 200 -0.13980  -0.0116
 Permethrin_rouge F - Permethrin_rouge M  -0.0106 0.0170 200 -0.05469   0.0335
 Control M - Permethrin_rouge M            0.0651 0.0176 200  0.01947   0.1107
 t.ratio p.value
   3.697  0.0016
  -0.623  0.9246
   2.250  0.1136
  -3.058  0.0134
  -0.623  0.9246
   3.697  0.0016

Note: contrasts are still on the sqrt scale 
Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
P value adjustment: tukey method for comparing a family of 4 estimates 

Traveled distance moving

Code
ggplot(data_rouge_inf20)+
  geom_boxplot(aes(x=Traitement, y=Traveled_Dist_Moving, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Traveled_Dist_Moving, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
hist(data_rouge_inf20$Traveled_Dist_Moving)

Code
modTVM <- glmmTMB(Traveled_Dist_Moving~Traitement*sexe+(1|Replicat), 
                  data=data_rouge_inf20)
Anova(modTVM)
Analysis of Deviance Table (Type II Wald chisquare tests)

Response: Traveled_Dist_Moving
                  Chisq Df Pr(>Chisq)    
Traitement      18.9752  1  1.324e-05 ***
sexe             1.7103  1     0.1910    
Traitement:sexe  0.0024  1     0.9612    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
modTVM <- glmmTMB(Traveled_Dist_Moving~Traitement+sexe+(1|Replicat), 
                  data=data_rouge_inf20, family=nbinom1())
summary(modTVM)
 Family: nbinom1  ( log )
Formula:          Traveled_Dist_Moving ~ Traitement + sexe + (1 | Replicat)
Data: data_rouge_inf20

     AIC      BIC   logLik deviance df.resid 
  2609.4   2626.0  -1299.7   2599.4      200 

Random effects:

Conditional model:
 Groups   Name        Variance Std.Dev.
 Replicat (Intercept) 0.3074   0.5545  
Number of obs: 205, groups:  Replicat, 4

Dispersion parameter for nbinom1 family ():  188 

Conditional model:
                           Estimate Std. Error z value Pr(>|z|)    
(Intercept)                 5.51273    0.29205  18.876  < 2e-16 ***
TraitementPermethrin_rouge -0.51722    0.11285  -4.583 4.58e-06 ***
sexeM                       0.03535    0.10208   0.346    0.729    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
res <- simulateResiduals(modTVM)
plot(res)

Code
# transfo

modTVM <- glmmTMB(sqrt(Traveled_Dist_Moving)~Traitement+sexe+(1|Replicat), 
                  data=data_rouge_inf20)
res <- simulateResiduals(modTVM)
plot(res)

Code
Anova(modTVM)# sors pas mais modèle meilleur avec variable sexe 
Analysis of Deviance Table (Type II Wald chisquare tests)

Response: sqrt(Traveled_Dist_Moving)
             Chisq Df Pr(>Chisq)    
Traitement 16.9192  1  3.901e-05 ***
sexe        0.6235  1     0.4298    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
emmeans(modTVM, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement       sexe response   SE  df lower.CL upper.CL t.ratio p.value
 Control          F         221 67.5 200    107.9      374   6.546  <.0001
 Permethrin_rouge F         124 51.9 200     42.7      247   4.776  <.0001
 Control          M         242 70.9 200    122.4      402   6.829  <.0001
 Permethrin_rouge M         140 55.1 200     52.3      270   5.074  <.0001

Confidence level used: 0.95 
Intervals are back-transformed from the sqrt scale 
Tests are performed on the sqrt scale 

$contrasts
 contrast                                estimate    SE  df lower.CL upper.CL
 Control F - Permethrin_rouge F             3.731 0.907 200    1.381     6.08
 Control F - Control M                     -0.692 0.877 200   -2.964     1.58
 Control F - Permethrin_rouge M             3.038 1.248 200   -0.194     6.27
 Permethrin_rouge F - Control M            -4.423 1.275 200   -7.726    -1.12
 Permethrin_rouge F - Permethrin_rouge M   -0.692 0.877 200   -2.964     1.58
 Control M - Permethrin_rouge M             3.731 0.907 200    1.381     6.08
 t.ratio p.value
   4.113  0.0003
  -0.790  0.8591
   2.435  0.0738
  -3.468  0.0036
  -0.790  0.8591
   4.113  0.0003

Note: contrasts are still on the sqrt scale 
Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
P value adjustment: tukey method for comparing a family of 4 estimates 

avg speed moving

Code
ggplot(data_rouge_inf20)+
  geom_boxplot(aes(x=Traitement, y=Average_Speed_Moving, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Average_Speed_Moving, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
modAVM <- glmmTMB(Average_Speed_Moving~Traitement*sexe+(1|Replicat), 
                  data=data_orange_inf20)

Anova(modAVM)
Analysis of Deviance Table (Type II Wald chisquare tests)

Response: Average_Speed_Moving
                 Chisq Df Pr(>Chisq)
Traitement      2.5755  1     0.1085
sexe            0.5816  1     0.4457
Traitement:sexe 0.3221  1     0.5704
Code
modAVM <- glmmTMB(Average_Speed_Moving~Traitement+sexe+(1|Replicat), 
                  data=data_rouge_inf20)

res <- simulateResiduals(modAVM)
plot(res)

Code
summary(modAVM)
 Family: gaussian  ( identity )
Formula:          Average_Speed_Moving ~ Traitement + sexe + (1 | Replicat)
Data: data_rouge_inf20

     AIC      BIC   logLik deviance df.resid 
  -145.0   -128.6     77.5   -155.0      193 

Random effects:

Conditional model:
 Groups   Name        Variance Std.Dev.
 Replicat (Intercept) 0.002212 0.04704 
 Residual             0.025954 0.16110 
Number of obs: 198, groups:  Replicat, 4

Dispersion estimate for gaussian family (sigma^2): 0.026 

Conditional model:
                           Estimate Std. Error z value Pr(>|z|)    
(Intercept)                 0.73279    0.03054  23.991   <2e-16 ***
TraitementPermethrin_rouge -0.03413    0.02356  -1.449    0.147    
sexeM                      -0.01548    0.02294  -0.675    0.500    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
emmeans(modAVM, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement       sexe emmean     SE  df lower.CL upper.CL t.ratio p.value
 Control          F     0.733 0.0305 193    0.673    0.793  23.991  <.0001
 Permethrin_rouge F     0.699 0.0330 193    0.634    0.764  21.158  <.0001
 Control          M     0.717 0.0309 193    0.656    0.778  23.195  <.0001
 Permethrin_rouge M     0.683 0.0329 193    0.618    0.748  20.741  <.0001

Confidence level used: 0.95 

$contrasts
 contrast                                estimate     SE  df lower.CL upper.CL
 Control F - Permethrin_rouge F            0.0341 0.0236 193  -0.0269   0.0952
 Control F - Control M                     0.0155 0.0229 193  -0.0440   0.0749
 Control F - Permethrin_rouge M            0.0496 0.0324 193  -0.0345   0.1337
 Permethrin_rouge F - Control M           -0.0186 0.0333 193  -0.1050   0.0677
 Permethrin_rouge F - Permethrin_rouge M   0.0155 0.0229 193  -0.0440   0.0749
 Control M - Permethrin_rouge M            0.0341 0.0236 193  -0.0269   0.0952
 t.ratio p.value
   1.449  0.4705
   0.675  0.9065
   1.529  0.4219
  -0.560  0.9438
   0.675  0.9065
   1.449  0.4705

Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
P value adjustment: tukey method for comparing a family of 4 estimates 

Max bout inactiv

Code
ggplot(data_rouge_inf20)+
  geom_boxplot(aes(x=Traitement, y=Max_bout_inactiv, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Max_bout_inactiv, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
modMI <- glmmTMB(Max_bout_inactiv~Traitement+sexe+(1|Replicat), 
                 data=data_rouge_inf20, family=nbinom2(), zi=~1)


res <- simulateResiduals(modMI)
plot(res)

Code
summary(modMI)
 Family: nbinom2  ( log )
Formula:          Max_bout_inactiv ~ Traitement + sexe + (1 | Replicat)
Zero inflation:                    ~1
Data: data_rouge_inf20

     AIC      BIC   logLik deviance df.resid 
  3037.4   3057.3  -1512.7   3025.4      196 

Random effects:

Conditional model:
 Groups   Name        Variance Std.Dev.
 Replicat (Intercept) 0.1283   0.3582  
Number of obs: 202, groups:  Replicat, 4

Dispersion parameter for nbinom2 family (): 1.22 

Conditional model:
                           Estimate Std. Error z value Pr(>|z|)    
(Intercept)                  6.4222     0.2111  30.429   <2e-16 ***
TraitementPermethrin_rouge   0.1765     0.1357   1.301    0.193    
sexeM                        0.1704     0.1285   1.326    0.185    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Zero-inflation model:
            Estimate Std. Error z value Pr(>|z|)
(Intercept)   -20.73    2230.96  -0.009    0.993
Code
emmeans(modMI, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement       sexe response  SE  df asymp.LCL asymp.UCL null z.ratio
 Control          F         615 130 Inf       407       931    1  30.429
 Permethrin_rouge F         734 162 Inf       476      1132    1  29.834
 Control          M         730 154 Inf       482      1104    1  31.174
 Permethrin_rouge M         870 196 Inf       559      1355    1  29.995
 p.value
  <.0001
  <.0001
  <.0001
  <.0001

Confidence level used: 0.95 
Intervals are back-transformed from the log scale 
Tests are performed on the log scale 

$contrasts
 contrast                                ratio    SE  df asymp.LCL asymp.UCL
 Control F / Permethrin_rouge F          0.838 0.114 Inf     0.592      1.19
 Control F / Control M                   0.843 0.108 Inf     0.606      1.17
 Control F / Permethrin_rouge M          0.707 0.135 Inf     0.432      1.16
 Permethrin_rouge F / Control M          1.006 0.183 Inf     0.631      1.61
 Permethrin_rouge F / Permethrin_rouge M 0.843 0.108 Inf     0.606      1.17
 Control M / Permethrin_rouge M          0.838 0.114 Inf     0.592      1.19
 null z.ratio p.value
    1  -1.301  0.5622
    1  -1.326  0.5461
    1  -1.810  0.2686
    1   0.034  1.0000
    1  -1.326  0.5461
    1  -1.301  0.5622

Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
Intervals are back-transformed from the log scale 
P value adjustment: tukey method for comparing a family of 4 estimates 
Tests are performed on the log scale 

Max bout activ

Code
ggplot(data_rouge_inf20)+
  geom_boxplot(aes(x=Traitement, y=Max_bout_activ, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Max_bout_activ, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
# modMAct <- glmmTMB(Max_bout_activ~Traitement+sexe+(1|Replicat), 
#                  data=data_rouge_inf20, family=nbinom2(), zi=~1)
# 
# 
# res <- simulateResiduals(modMI)
# plot(res)
# 
# summary(modMI)
# emmeans(modMI, pairwise~Traitement+sexe, infer=TRUE, type="response")

Max speed

Code
ggplot(data_rouge_inf20)+
  geom_boxplot(aes(x=Traitement, y=Max_speed, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Max_speed, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
modMS <- glmmTMB(Max_speed~Traitement+sexe+(1|Replicat), 
                 data=data_rouge_inf20)
summary(modMS)
 Family: gaussian  ( identity )
Formula:          Max_speed ~ Traitement + sexe + (1 | Replicat)
Data: data_rouge_inf20

     AIC      BIC   logLik deviance df.resid 
   387.1    403.6   -188.5    377.1      197 

Random effects:

Conditional model:
 Groups   Name        Variance Std.Dev.
 Replicat (Intercept) 0.1560   0.3950  
 Residual             0.3572   0.5977  
Number of obs: 202, groups:  Replicat, 4

Dispersion estimate for gaussian family (sigma^2): 0.357 

Conditional model:
                           Estimate Std. Error z value Pr(>|z|)    
(Intercept)                  2.4800     0.2103  11.793   <2e-16 ***
TraitementPermethrin_rouge  -0.1026     0.0871  -1.178   0.2389    
sexeM                       -0.1520     0.0843  -1.803   0.0713 .  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
res <- simulateResiduals(modMS)
plot(res)

Code
emmeans(modMS, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement       sexe emmean    SE  df lower.CL upper.CL t.ratio p.value
 Control          F      2.48 0.210 197     2.07     2.89  11.793  <.0001
 Permethrin_rouge F      2.38 0.216 197     1.95     2.80  11.000  <.0001
 Control          M      2.33 0.211 197     1.91     2.74  11.025  <.0001
 Permethrin_rouge M      2.23 0.216 197     1.80     2.65  10.300  <.0001

Confidence level used: 0.95 

$contrasts
 contrast                                estimate     SE  df lower.CL upper.CL
 Control F - Permethrin_rouge F            0.1026 0.0871 197  -0.1231    0.328
 Control F - Control M                     0.1520 0.0843 197  -0.0664    0.370
 Control F - Permethrin_rouge M            0.2546 0.1196 197  -0.0552    0.564
 Permethrin_rouge F - Control M            0.0494 0.1228 197  -0.2689    0.368
 Permethrin_rouge F - Permethrin_rouge M   0.1520 0.0843 197  -0.0664    0.370
 Control M - Permethrin_rouge M            0.1026 0.0871 197  -0.1231    0.328
 t.ratio p.value
   1.178  0.6416
   1.803  0.2749
   2.129  0.1474
   0.402  0.9779
   1.803  0.2749
   1.178  0.6416

Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
P value adjustment: tukey method for comparing a family of 4 estimates 

Latency

Code
ggplot(data_rouge_SP)+
  geom_boxplot(aes(x=Traitement, y=Latency, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Latency, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
hist(data_orange_SP$Latency)

Code
modLat <- glmmTMB(Latency~Traitement+sexe+(1|Replicat), 
                             data=data_rouge_SP, family=nbinom1())
res <- simulateResiduals(modLat)
plot(res)

Code
summary(modLat)
 Family: nbinom1  ( log )
Formula:          Latency ~ Traitement + sexe + (1 | Replicat)
Data: data_rouge_SP

     AIC      BIC   logLik deviance df.resid 
   970.8    987.5   -480.4    960.8      203 

Random effects:

Conditional model:
 Groups   Name        Variance  Std.Dev. 
 Replicat (Intercept) 3.366e-09 5.801e-05
Number of obs: 208, groups:  Replicat, 4

Dispersion parameter for nbinom1 family ():  470 

Conditional model:
                           Estimate Std. Error z value Pr(>|z|)    
(Intercept)                  3.5949     0.2916   12.33   <2e-16 ***
TraitementPermethrin_rouge  -0.3291     0.2402   -1.37    0.171    
sexeM                        0.1179     0.2266    0.52    0.603    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
emmeans(modLat, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement       sexe response    SE  df asymp.LCL asymp.UCL null z.ratio
 Control          F        36.4 10.62 Inf      20.6      64.5    1  12.327
 Permethrin_rouge F        26.2  8.71 Inf      13.7      50.3    1   9.824
 Control          M        41.0 11.81 Inf      23.3      72.1    1  12.874
 Permethrin_rouge M        29.5  9.37 Inf      15.8      55.0    1  10.648
 p.value
  <.0001
  <.0001
  <.0001
  <.0001

Confidence level used: 0.95 
Intervals are back-transformed from the log scale 
Tests are performed on the log scale 

$contrasts
 contrast                                ratio    SE  df asymp.LCL asymp.UCL
 Control F / Permethrin_rouge F          1.390 0.334 Inf     0.750      2.58
 Control F / Control M                   0.889 0.201 Inf     0.497      1.59
 Control F / Permethrin_rouge M          1.235 0.393 Inf     0.545      2.80
 Permethrin_rouge F / Control M          0.639 0.218 Inf     0.266      1.54
 Permethrin_rouge F / Permethrin_rouge M 0.889 0.201 Inf     0.497      1.59
 Control M / Permethrin_rouge M          1.390 0.334 Inf     0.750      2.58
 null z.ratio p.value
    1   1.370  0.5181
    1  -0.520  0.9542
    1   0.663  0.9109
    1  -1.309  0.5573
    1  -0.520  0.9542
    1   1.370  0.5181

Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
Intervals are back-transformed from the log scale 
P value adjustment: tukey method for comparing a family of 4 estimates 
Tests are performed on the log scale 

Prop time alongside walls

Code
ggplot(data_rouge_SP)+
  geom_boxplot(aes(x=Traitement, y=Prop_time_inside, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Prop_time_inside, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
modPTIW <- glmmTMB(sqrt(Prop_time_inside)~Traitement+sexe+(1|Replicat), 
                             data=data_rouge_SP)
res <- simulateResiduals(modPTIW)
plot(res)

Code
summary(modPTIW)
 Family: gaussian  ( identity )
Formula:          sqrt(Prop_time_inside) ~ Traitement + sexe + (1 | Replicat)
Data: data_rouge_SP

     AIC      BIC   logLik deviance df.resid 
  -242.1   -225.4    126.0   -252.1      203 

Random effects:

Conditional model:
 Groups   Name        Variance Std.Dev.
 Replicat (Intercept) 0.003559 0.05966 
 Residual             0.016665 0.12909 
Number of obs: 208, groups:  Replicat, 4

Dispersion estimate for gaussian family (sigma^2): 0.0167 

Conditional model:
                           Estimate Std. Error z value Pr(>|z|)    
(Intercept)                 0.81408    0.03358  24.242  < 2e-16 ***
TraitementPermethrin_rouge  0.05131    0.01856   2.764  0.00571 ** 
sexeM                      -0.02488    0.01794  -1.387  0.16550    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
emmeans(modPTIW, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement       sexe response     SE  df lower.CL upper.CL t.ratio p.value
 Control          F       0.663 0.0547 203    0.559    0.775  24.242  <.0001
 Permethrin_rouge F       0.749 0.0610 203    0.633    0.874  24.552  <.0001
 Control          M       0.623 0.0532 203    0.522    0.732  23.415  <.0001
 Permethrin_rouge M       0.706 0.0591 203    0.595    0.828  23.893  <.0001

Confidence level used: 0.95 
Intervals are back-transformed from the sqrt scale 
Tests are performed on the sqrt scale 

$contrasts
 contrast                                estimate     SE  df lower.CL upper.CL
 Control F - Permethrin_rouge F           -0.0513 0.0186 203 -0.09940 -0.00323
 Control F - Control M                     0.0249 0.0179 203 -0.02160  0.07137
 Control F - Permethrin_rouge M           -0.0264 0.0256 203 -0.09265  0.03979
 Permethrin_rouge F - Control M            0.0762 0.0261 203  0.00866  0.14373
 Permethrin_rouge F - Permethrin_rouge M   0.0249 0.0179 203 -0.02160  0.07137
 Control M - Permethrin_rouge M           -0.0513 0.0186 203 -0.09940 -0.00323
 t.ratio p.value
  -2.764  0.0314
   1.387  0.5091
  -1.034  0.7298
   2.923  0.0200
   1.387  0.5091
  -2.764  0.0314

Note: contrasts are still on the sqrt scale 
Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
P value adjustment: tukey method for comparing a family of 4 estimates 

Prop time moving alongside walls

Code
ggplot(data_rouge_SP)+
  geom_boxplot(aes(x=Traitement, y=Prop_time_moving, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Prop_time_moving, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
modPTMs<- glmmTMB(sqrt(Prop_time_moving)~Traitement+sexe+(1|Replicat), 
                             data=data_rouge_SP)
res <- simulateResiduals(modPTMs)
plot(res)

Code
summary(modPTMs)
 Family: gaussian  ( identity )
Formula:          sqrt(Prop_time_moving) ~ Traitement + sexe + (1 | Replicat)
Data: data_rouge_SP

     AIC      BIC   logLik deviance df.resid 
  -314.1   -297.4    162.1   -324.1      203 

Random effects:

Conditional model:
 Groups   Name        Variance Std.Dev.
 Replicat (Intercept) 0.004425 0.06652 
 Residual             0.011670 0.10803 
Number of obs: 208, groups:  Replicat, 4

Dispersion estimate for gaussian family (sigma^2): 0.0117 

Conditional model:
                            Estimate Std. Error z value Pr(>|z|)    
(Intercept)                 0.220887   0.035702   6.187 6.13e-10 ***
TraitementPermethrin_rouge -0.046528   0.015531  -2.996  0.00274 ** 
sexeM                       0.008154   0.015020   0.543  0.58721    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
emmeans(modPTMs, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement       sexe response     SE  df lower.CL upper.CL t.ratio p.value
 Control          F      0.0488 0.0158 203   0.0226   0.0848   6.187  <.0001
 Permethrin_rouge F      0.0304 0.0128 203   0.0104   0.0610   4.736  <.0001
 Control          M      0.0525 0.0164 203   0.0251   0.0898   6.398  <.0001
 Permethrin_rouge M      0.0333 0.0134 203   0.0121   0.0651   4.961  <.0001

Confidence level used: 0.95 
Intervals are back-transformed from the sqrt scale 
Tests are performed on the sqrt scale 

$contrasts
 contrast                                estimate     SE  df lower.CL upper.CL
 Control F - Permethrin_rouge F           0.04653 0.0155 203   0.0063  0.08676
 Control F - Control M                   -0.00815 0.0150 203  -0.0471  0.03076
 Control F - Permethrin_rouge M           0.03837 0.0214 203  -0.0171  0.09381
 Permethrin_rouge F - Control M          -0.05468 0.0218 203  -0.1112  0.00181
 Permethrin_rouge F - Permethrin_rouge M -0.00815 0.0150 203  -0.0471  0.03076
 Control M - Permethrin_rouge M           0.04653 0.0155 203   0.0063  0.08676
 t.ratio p.value
   2.996  0.0161
  -0.543  0.9484
   1.793  0.2796
  -2.507  0.0618
  -0.543  0.9484
   2.996  0.0161

Note: contrasts are still on the sqrt scale 
Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
P value adjustment: tukey method for comparing a family of 4 estimates 

Nb entries

Code
ggplot(data_rouge_SP)+
  geom_boxplot(aes(x=Traitement, y=Nb_entries, colour=Traitement))+
  geom_jitter(aes(x=Traitement, y=Nb_entries, colour=Traitement))+
  theme(axis.text.x = element_blank(), axis.ticks = element_blank())

Code
modNbE<- glmmTMB(Nb_entries~Traitement+sexe+(1|Replicat), 
                             data=data_rouge_SP, family=nbinom1())
res <- simulateResiduals(modNbE)
plot(res)

Code
summary(modNbE)
 Family: nbinom1  ( log )
Formula:          Nb_entries ~ Traitement + sexe + (1 | Replicat)
Data: data_rouge_SP

     AIC      BIC   logLik deviance df.resid 
  2270.6   2287.3  -1130.3   2260.6      203 

Random effects:

Conditional model:
 Groups   Name        Variance Std.Dev.
 Replicat (Intercept) 0.09915  0.3149  
Number of obs: 208, groups:  Replicat, 4

Dispersion parameter for nbinom1 family ():   41 

Conditional model:
                           Estimate Std. Error z value Pr(>|z|)    
(Intercept)                 4.66766    0.17287  27.000  < 2e-16 ***
TraitementPermethrin_rouge -0.40131    0.08732  -4.596 4.31e-06 ***
sexeM                       0.02320    0.08136   0.285    0.776    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
emmeans(modNbE, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement       sexe response   SE  df asymp.LCL asymp.UCL null z.ratio
 Control          F       106.4 18.4 Inf      75.9       149    1  27.000
 Permethrin_rouge F        71.3 13.0 Inf      49.8       102    1  23.367
 Control          M       108.9 18.9 Inf      77.6       153    1  27.073
 Permethrin_rouge M        72.9 13.4 Inf      50.9       105    1  23.350
 p.value
  <.0001
  <.0001
  <.0001
  <.0001

Confidence level used: 0.95 
Intervals are back-transformed from the log scale 
Tests are performed on the log scale 

$contrasts
 contrast                                ratio     SE  df asymp.LCL asymp.UCL
 Control F / Permethrin_rouge F          1.494 0.1304 Inf     1.194     1.869
 Control F / Control M                   0.977 0.0795 Inf     0.793     1.204
 Control F / Permethrin_rouge M          1.460 0.1759 Inf     1.071     1.989
 Permethrin_rouge F / Control M          0.654 0.0773 Inf     0.483     0.886
 Permethrin_rouge F / Permethrin_rouge M 0.977 0.0795 Inf     0.793     1.204
 Control M / Permethrin_rouge M          1.494 0.1304 Inf     1.194     1.869
 null z.ratio p.value
    1   4.596  <.0001
    1  -0.285  0.9919
    1   3.138  0.0092
    1  -3.592  0.0019
    1  -0.285  0.9919
    1   4.596  <.0001

Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
Intervals are back-transformed from the log scale 
P value adjustment: tukey method for comparing a family of 4 estimates 
Tests are performed on the log scale 

Survie

Code
library(survminer)
library(survival)
 
data_complete <- data_complete %>%  mutate(surv_bin = ifelse(!is.na(date_mort2), 1, NA))
surv_time <- survfit(Surv(duree_vie,surv_bin)~Traitement, data=data_complete) # survival object for graph
ggsurvplot(surv_time, data = data_complete, facet.by = "sexe", legend.title = "Pupaison time")#KM plot

Code
surv_time_s <- survfit(Surv(duree_vie,surv_bin)~sexe, data=data_complete) # survival object for graph
ggsurvplot(surv_time_s, data = data_complete, facet.by = "Traitement", legend.title = "Pupaison time")#KM plot

Code
summary(surv_time)# 100 obs lost due to missingness. NA= non observed, may I infer on the day before ? 
Call: survfit(formula = Surv(duree_vie, surv_bin) ~ Traitement, data = data_complete)

120 observations deleted due to missingness 
                Traitement=Control 
 time n.risk n.event survival std.err lower 95% CI upper 95% CI
   -5    207       1  0.99517 0.00482     0.985768       1.0000
    8    206       1  0.99034 0.00680     0.977102       1.0000
    9    205       5  0.96618 0.01256     0.941871       0.9911
   10    200      10  0.91787 0.01908     0.881224       0.9560
   11    190       9  0.87440 0.02303     0.830396       0.9207
   12    181       2  0.86473 0.02377     0.819377       0.9126
   13    179      11  0.81159 0.02718     0.760035       0.8667
   14    168       1  0.80676 0.02744     0.754730       0.8624
   15    167       2  0.79710 0.02795     0.744157       0.8538
   17    165       2  0.78744 0.02844     0.733633       0.8452
   18    163       2  0.77778 0.02890     0.723156       0.8365
   19    161       4  0.75845 0.02975     0.702331       0.8191
   20    157      10  0.71014 0.03153     0.650953       0.7747
   21    147       1  0.70531 0.03169     0.645864       0.7702
   22    146      15  0.63285 0.03350     0.570477       0.7020
   24    131      13  0.57005 0.03441     0.506443       0.6416
   25    118      18  0.48309 0.03473     0.419596       0.5562
   26    100      16  0.40580 0.03413     0.344126       0.4785
   27     84      12  0.34783 0.03310     0.288636       0.4192
   28     72      17  0.26570 0.03070     0.211855       0.3332
   29     55      11  0.21256 0.02844     0.163535       0.2763
   30     44       3  0.19807 0.02770     0.150581       0.2605
   31     41       1  0.19324 0.02744     0.146286       0.2553
   32     40      17  0.11111 0.02184     0.075582       0.1633
   33     23       1  0.10628 0.02142     0.071596       0.1578
   34     22       5  0.08213 0.01908     0.052082       0.1295
   35     17       2  0.07246 0.01802     0.044510       0.1180
   36     15       3  0.05797 0.01624     0.033475       0.1004
   37     12       1  0.05314 0.01559     0.029901       0.0944
   38     11       4  0.03382 0.01256     0.016326       0.0700
   39      7       2  0.02415 0.01067     0.010161       0.0574
   42      5       2  0.01449 0.00831     0.004713       0.0446
   45      3       1  0.00966 0.00680     0.002433       0.0384
   46      2       1  0.00483 0.00482     0.000684       0.0341
   51      1       1  0.00000     NaN           NA           NA

                Traitement=Permethrin_orange 
 time n.risk n.event survival std.err lower 95% CI upper 95% CI
    9     98       1   0.9898  0.0102      0.97010       1.0000
   11     97       2   0.9694  0.0174      0.93587       1.0000
   12     95       2   0.9490  0.0222      0.90640       0.9936
   13     93       8   0.8673  0.0343      0.80272       0.9372
   15     85       2   0.8469  0.0364      0.77857       0.9213
   21     83       3   0.8163  0.0391      0.74315       0.8967
   22     80       7   0.7449  0.0440      0.66340       0.8364
   24     73       9   0.6531  0.0481      0.56530       0.7544
   25     64       8   0.5714  0.0500      0.48139       0.6783
   27     56       9   0.4796  0.0505      0.39021       0.5894
   28     47       5   0.4286  0.0500      0.34099       0.5387
   29     42       9   0.3367  0.0477      0.25504       0.4446
   30     33       1   0.3265  0.0474      0.24572       0.4339
   31     32       2   0.3061  0.0466      0.22722       0.4124
   32     30       6   0.2449  0.0434      0.17298       0.3467
   34     24       7   0.1735  0.0382      0.11260       0.2672
   36     17       5   0.1224  0.0331      0.07207       0.2080
   37     12       4   0.0816  0.0277      0.04202       0.1586
   38      8       4   0.0408  0.0200      0.01563       0.1066
   41      4       1   0.0306  0.0174      0.01005       0.0933
   43      3       1   0.0204  0.0143      0.00518       0.0804
   44      2       1   0.0102  0.0102      0.00145       0.0717
   51      1       1   0.0000     NaN           NA           NA

                Traitement=Permethrin_rouge 
 time n.risk n.event survival std.err lower 95% CI upper 95% CI
   -3    102       1   0.9902 0.00976      0.97126       1.0000
    8    101       2   0.9706 0.01673      0.93835       1.0000
    9     99       1   0.9608 0.01922      0.92384       0.9992
   10     98       7   0.8922 0.03071      0.83395       0.9544
   11     91      10   0.7941 0.04004      0.71940       0.8766
   12     81       4   0.7549 0.04259      0.67588       0.8432
   13     77       5   0.7059 0.04512      0.62277       0.8001
   16     72       2   0.6863 0.04594      0.60188       0.7825
   17     70       4   0.6471 0.04732      0.56066       0.7468
   18     66       1   0.6373 0.04761      0.55046       0.7377
   19     65       2   0.6176 0.04812      0.53019       0.7195
   20     63       3   0.5882 0.04873      0.50008       0.6919
   22     60       8   0.5098 0.04950      0.42146       0.6167
   23     52       2   0.4902 0.04950      0.40218       0.5975
   24     50       1   0.4804 0.04947      0.39259       0.5878
   25     49      15   0.3333 0.04668      0.25333       0.4386
   26     34      13   0.2059 0.04004      0.14064       0.3014
   28     21       5   0.1569 0.03601      0.10003       0.2460
   29     16       5   0.1078 0.03071      0.06171       0.1885
   30     11       2   0.0882 0.02808      0.04728       0.1647
   32      9       6   0.0294 0.01673      0.00965       0.0897
   35      3       1   0.0196 0.01373      0.00497       0.0773
   36      2       1   0.0098 0.00976      0.00139       0.0689
   46      1       1   0.0000     NaN           NA           NA
Code
median(surv_time)
                             50
Traitement=Control           25
Traitement=Permethrin_orange 27
Traitement=Permethrin_rouge  23
Code
test_logrank <- survdiff(Surv(duree_vie,surv_bin) ~ Traitement, data = data_complete)
test_logrank
Call:
survdiff(formula = Surv(duree_vie, surv_bin) ~ Traitement, data = data_complete)

n=407, 120 observations deleted due to missingness.

                               N Observed Expected (O-E)^2/E (O-E)^2/V
Traitement=Control           207      207    206.7  3.67e-04  8.68e-04
Traitement=Permethrin_orange  98       98    129.1  7.50e+00  1.31e+01
Traitement=Permethrin_rouge  102      102     71.2  1.34e+01  1.88e+01

 Chisq= 24.7  on 2 degrees of freedom, p= 4e-06 
Code
test_logrank_s <- survdiff(Surv(duree_vie,surv_bin) ~ sexe, data = data_complete)
test_logrank_s
Call:
survdiff(formula = Surv(duree_vie, surv_bin) ~ sexe, data = data_complete)

n=354, 173 observations deleted due to missingness.

         N Observed Expected (O-E)^2/E (O-E)^2/V
sexe=F 174      174      188      1.02      2.61
sexe=M 180      180      166      1.16      2.61

 Chisq= 2.6  on 1 degrees of freedom, p= 0.1 
Code
library(coxme)
# orange
data_orange <- data_complete %>% filter(Experiment=="Orange") %>% droplevels()
cox_orange <- coxme(Surv(duree_vie,surv_bin) ~ Traitement+sexe+(1|Replicat), data = data_orange)
summary(cox_orange)
Mixed effects coxme model
 Formula: Surv(duree_vie, surv_bin) ~ Traitement + sexe + (1 | Replicat) 
    Data: data_orange 

  events, n = 166, 166 (74 observations deleted due to missingness)

Random effects:
     group  variable          sd     variance
1 Replicat Intercept 0.009331707 8.708076e-05
                  Chisq   df      p   AIC    BIC
Integrated loglik  0.16 3.00 0.9836 -5.84 -15.18
 Penalized loglik  0.18 2.01 0.9145 -3.84 -10.10

Fixed effects:
                               coef exp(coef) se(coef)    z     p
TraitementPermethrin_orange 0.05689   1.05854  0.15980 0.36 0.722
sexeM                       0.02138   1.02161  0.15918 0.13 0.893
Code
# rouge 

data_rouge <- data_complete %>% filter(Experiment=="Rouge") %>% droplevels()
cox_rouge <- coxme(Surv(duree_vie,surv_bin) ~ Traitement*sexe+(1|Replicat), data = data_rouge)
summary(cox_rouge)
Mixed effects coxme model
 Formula: Surv(duree_vie, surv_bin) ~ Traitement * sexe + (1 | Replicat) 
    Data: data_rouge 

  events, n = 188, 188 (99 observations deleted due to missingness)

Random effects:
     group  variable       sd variance
1 Replicat Intercept 1.011207 1.022539
                  Chisq   df         p   AIC   BIC
Integrated loglik 70.38 4.00 1.887e-14 62.38 49.44
 Penalized loglik 84.05 5.91 4.441e-16 72.24 53.13

Fixed effects:
                                     coef exp(coef) se(coef)     z      p
TraitementPermethrin_rouge       -0.01081   0.98925  0.21904 -0.05 0.9606
sexeM                             0.48908   1.63081  0.20071  2.44 0.0148
TraitementPermethrin_rouge:sexeM  0.04699   1.04811  0.29977  0.16 0.8754
Code
emmeans(cox_rouge, pairwise~Traitement+sexe, infer=TRUE, type="response")
$emmeans
 Traitement       sexe response    SE  df asymp.LCL asymp.UCL null z.ratio
 Control          F       0.763 0.100 Inf     0.589     0.987    1  -2.058
 Permethrin_rouge F       0.754 0.108 Inf     0.570     0.999    1  -1.968
 Control          M       1.244 0.136 Inf     1.003     1.541    1   1.990
 Permethrin_rouge M       1.289 0.182 Inf     0.978     1.700    1   1.803
 p.value
  0.0396
  0.0491
  0.0466
  0.0714

Confidence level used: 0.95 
Intervals are back-transformed from the log scale 
Tests are performed on the log scale 

$contrasts
 contrast                                ratio    SE  df asymp.LCL asymp.UCL
 Control F / Permethrin_rouge F          1.011 0.221 Inf     0.576      1.77
 Control F / Control M                   0.613 0.123 Inf     0.366      1.03
 Control F / Permethrin_rouge M          0.591 0.131 Inf     0.335      1.04
 Permethrin_rouge F / Control M          0.607 0.128 Inf     0.353      1.04
 Permethrin_rouge F / Permethrin_rouge M 0.585 0.134 Inf     0.325      1.05
 Control M / Permethrin_rouge M          0.964 0.199 Inf     0.567      1.64
 null z.ratio p.value
    1   0.049  1.0000
    1  -2.437  0.0703
    1  -2.374  0.0821
    1  -2.368  0.0833
    1  -2.342  0.0888
    1  -0.175  0.9981

Confidence level used: 0.95 
Conf-level adjustment: tukey method for comparing a family of 4 estimates 
Intervals are back-transformed from the log scale 
P value adjustment: tukey method for comparing a family of 4 estimates 
Tests are performed on the log scale 

Nymphose

Code
data_complete <- data_complete %>%  mutate(nymph_bin = ifelse(!is.na(date_adulte2), 1, NA))
surv_time <- survfit(Surv(duree_vie,surv_bin)~Traitement, data=data_complete) # survival object for graph
ggsurvplot(surv_time, data = data_complete, facet.by = "sexe", legend.title = "Pupaison time")#KM plot

Adulte

Code
data_complete <- data_complete %>%  
  mutate(dvpt_ad=case_when(
    is.na(date_adulte2) & !is.na(date_mort2)  ~ 0,
     !is.na(date_adulte2)  ~ 1,
    TRUE~ NA),
    duree_ad= date_adulte2 - date_eclosion2)
data_orange <- data_orange %>%  
  mutate(dvpt_ad=case_when(
    is.na(date_adulte2) & !is.na(date_mort2)  ~ 0,
     !is.na(date_adulte2)  ~ 1,
    TRUE~ NA),
    duree_ad= date_adulte2 - date_eclosion2)

data_rouge <- data_rouge %>%  
  mutate(dvpt_ad=case_when(
    is.na(date_adulte2) & !is.na(date_mort2)  ~ 0,
     !is.na(date_adulte2)  ~ 1,
    TRUE~ NA),
    duree_ad= date_adulte2 - date_eclosion2)

surv_time <- survfit(Surv(duree_ad,dvpt_ad)~Traitement, data=data_complete) # survival object for graph
ggsurvplot(surv_time, data = data_complete, facet.by = "sexe", legend.title = "Pupaison time")#KM plot

Code
median(surv_time)
                             50
Traitement=Control           11
Traitement=Permethrin_orange 13
Traitement=Permethrin_rouge  10
Code
test_logrank_ad <- survdiff(Surv(duree_ad,dvpt_ad) ~ Traitement, data = data_complete)
test_logrank_ad
Call:
survdiff(formula = Surv(duree_ad, dvpt_ad) ~ Traitement, data = data_complete)

n=460, 67 observations deleted due to missingness.

                               N Observed Expected (O-E)^2/E (O-E)^2/V
Traitement=Control           244      244    219.3      2.78      10.4
Traitement=Permethrin_orange 103      103    156.4     18.21      60.3
Traitement=Permethrin_rouge  113      113     84.3      9.76      21.9

 Chisq= 65.9  on 2 degrees of freedom, p= 5e-15 
Code
# only pour les rouge 
cox_ad_rouge <- coxme(Surv(duree_ad,dvpt_ad) ~ Traitement+(1|Replicat), data = data_rouge)
summary(cox_ad_rouge)
Mixed effects coxme model
 Formula: Surv(duree_ad, dvpt_ad) ~ Traitement + (1 | Replicat) 
    Data: data_rouge 

  events, n = 250, 250 (37 observations deleted due to missingness)

Random effects:
     group  variable       sd variance
1 Replicat Intercept 1.298839 1.686982
                  Chisq   df p   AIC   BIC
Integrated loglik 176.9 2.00 0 172.9 165.8
 Penalized loglik 192.2 3.94 0 184.4 170.5

Fixed effects:
                              coef exp(coef) se(coef)     z        p
TraitementPermethrin_rouge -0.6764    0.5085   0.1357 -4.99 6.17e-07
Code
# only pour les orang
cox_ad_orange <- coxme(Surv(duree_ad,dvpt_ad) ~ Traitement+(1|Replicat), data = data_orange)
summary(cox_ad_orange)
Mixed effects coxme model
 Formula: Surv(duree_ad, dvpt_ad) ~ Traitement + (1 | Replicat) 
    Data: data_orange 

  events, n = 210, 210 (30 observations deleted due to missingness)

Random effects:
     group  variable        sd  variance
1 Replicat Intercept 0.8386643 0.7033579
                  Chisq   df p   AIC   BIC
Integrated loglik 81.60 2.00 0 77.60 70.91
 Penalized loglik 98.69 4.85 0 88.99 72.76

Fixed effects:
                               coef exp(coef) se(coef)     z      p
TraitementPermethrin_orange -0.3324    0.7172   0.1410 -2.36 0.0184
Code
# need to check residuals 
emmeans(cox_ad_rouge, pairwise~Traitement, infer=TRUE, type="response")
$emmeans
 Traitement       response     SE  df asymp.LCL asymp.UCL null z.ratio p.value
 Control              1.36 0.0832 Inf     1.204     1.531    1   4.986  <.0001
 Permethrin_rouge     0.69 0.0513 Inf     0.597     0.799    1  -4.986  <.0001

Confidence level used: 0.95 
Intervals are back-transformed from the log scale 
Tests are performed on the log scale 

$contrasts
 contrast                   ratio    SE  df asymp.LCL asymp.UCL null z.ratio
 Control / Permethrin_rouge  1.97 0.267 Inf      1.51      2.57    1   4.986
 p.value
  <.0001

Confidence level used: 0.95 
Intervals are back-transformed from the log scale 
Tests are performed on the log scale 
Code
emmeans(cox_ad_orange, pairwise~Traitement, infer=TRUE, type="response")
$emmeans
 Traitement        response     SE  df asymp.LCL asymp.UCL null z.ratio p.value
 Control              1.177 0.0814 Inf     1.028     1.348    1   2.357  0.0184
 Permethrin_orange    0.844 0.0607 Inf     0.733     0.972    1  -2.357  0.0184

Confidence level used: 0.95 
Intervals are back-transformed from the log scale 
Tests are performed on the log scale 

$contrasts
 contrast                    ratio    SE  df asymp.LCL asymp.UCL null z.ratio
 Control / Permethrin_orange  1.39 0.197 Inf      1.06      1.84    1   2.357
 p.value
  0.0184

Confidence level used: 0.95 
Intervals are back-transformed from the log scale 
Tests are performed on the log scale